package com.pai4j.remote.user;

import cn.dev33.satoken.stp.SaTokenInfo;
import com.pai4j.common.bean.PAIResponseBean;
import com.pai4j.domain.dto.BindWxRequestDTO;
import com.pai4j.domain.dto.UpdatePasswordDTO;
import com.pai4j.domain.vo.request.RegisterRequestDTO;
import com.pai4j.domain.vo.request.UpdateUserInfoResquest;
import com.pai4j.domain.vo.request.request.UserLoginInfoRequestVO;
import com.pai4j.domain.vo.request.request.UserRegistryInfoRequestVO;
import com.pai4j.domain.vo.response.UserBaseResponseInfoVO;
import com.pai4j.domain.vo.response.UserBaseResponseVO;
import com.pai4j.domain.vo.response.subjectaccount.SubjectBaseResponseVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

@FeignClient(name = "pai4j-user-service", contextId = "userServiceClient")
public interface UserServiceClient {
    /**
     * 登录
     */
    @GetMapping("/user-service/user/doLogin/{validCode}")
    PAIResponseBean<SaTokenInfo> doLogin(@PathVariable("validCode") String validCode);


    @PostMapping("/user-service/user/unified/login")
    PAIResponseBean<SaTokenInfo> unifiedLogin(@RequestBody UserLoginInfoRequestVO request);

    
    /**
     * 注册
     */
    @PostMapping( "/user-service/user/register")
    PAIResponseBean<Boolean> register(@RequestBody RegisterRequestDTO request);

    /**
     * 获取用户信息
     */
    @GetMapping("/user-service/user/info/{userId}")
    PAIResponseBean<UserBaseResponseInfoVO> getUserBaseInfo(@PathVariable("userId") String userId);
    
    
    /**
     * 更新用户信息
     */
    @PostMapping("/user-service/user/updateUserInfo")
    PAIResponseBean<Boolean> updateUserBaseInfo(@RequestBody UpdateUserInfoResquest updateUserInfoResquest);
    
    /**
     * 批量查询用户详情, 底层走Redis
     */
    @PostMapping("/user-service/account/batchGet")
    PAIResponseBean<Map<String, UserBaseResponseInfoVO>> batchGetMap(@RequestBody Set<String> userIds);
    
    /**
     *  批量查询用户详情缓存
     */
    @PostMapping("/user-service/account/batchGetList")
    PAIResponseBean<List<UserBaseResponseInfoVO>> batchGetList(@RequestBody List<String> userIds);
    
    
    /**
     * 获取群聊下所有用户id
     *
     * @param account
     * @return
     */
    @GetMapping("/user-service/subscriber/{relationType}/{account}")
    PAIResponseBean<Set<String>> getAllSubscriberByAccount(@PathVariable Integer relationType, @PathVariable String account);
    
    /**
     * 判断是否订阅
     *
     * @param account
     * @return
     */
    @GetMapping("/user-service/isSubscribe/{relationType}/{userAccount}/{account}")
    PAIResponseBean<Boolean> isSubscribe(@PathVariable Integer relationType, @PathVariable String userAccount, @PathVariable String account);
    
    /**
     * 根据用户昵称查询用户基础信息
     *
     * @param name
     * @return
     */
    @GetMapping("/user-service/user/name/info/{name}")
    PAIResponseBean<UserBaseResponseVO> userNameBaseInfo(@PathVariable String name);
    
    
    /**
     * 根据手机号查询用户基础信息
     *
     * @param mobile
     * @return
     */
    @GetMapping("/user-service/user/mobile/info/{mobile}")
    PAIResponseBean<UserBaseResponseVO> userBaseInfo(@PathVariable String mobile);
    
    
    /**
     * 新账号注册
     *
     * @param request
     * @return
     */
    @PostMapping("/user-service/user/picCheckCode/register")
    PAIResponseBean<Boolean> registry(@RequestBody UserRegistryInfoRequestVO request);
    
    @GetMapping("/user-service/user/info/sso/{uid}")
    PAIResponseBean<UserBaseResponseInfoVO> getUserBaseInfoByUid(@PathVariable("uid") String uid);
    
    /**
     * 绑定微信公众号
     *
     * @author: CYM-pai
     * @date: 2025/06/29 15:52
     **/
    @PostMapping("/user-service/user/bindWx")
    PAIResponseBean<Boolean> bindWx(@RequestBody BindWxRequestDTO request);
    
    
    @PostMapping("/user-service/user/password/update")
    PAIResponseBean<Boolean> updatePassword(@RequestBody UpdatePasswordDTO request);

    @GetMapping("/user-service/user/registerTime/{userId}")
    PAIResponseBean<String> getRegisterTime(@PathVariable("userId") String userId);

    /**
     * 混合搜索用户信息 - 支持用户名、手机号、uid三种方式搜索
     *
     * @param searchValue 搜索值（用户名/手机号/uid）
     * @return 用户基础信息
     */
    @GetMapping("/user-service/user/search/{searchValue}")
    PAIResponseBean<UserBaseResponseInfoVO> hybridSearch(@PathVariable("searchValue") String searchValue);
    
    String getLoginUserIdAndCheckoutAdmin();
    
    Map<String, UserBaseResponseInfoVO> batchGetUserInfoFromCache(List<String> userIdList);
    
    List<UserBaseResponseInfoVO> batchGetUserListInfoFromCache(ArrayList<String> strings);
    
    boolean isAdmin(String userId);
    
    UserBaseResponseInfoVO getUserInfoByUserId(String author);
    
    UserBaseResponseInfoVO getUserBaseInfoByUserId(String author);
    
    UserBaseResponseInfoVO getSystemUserInfo();
    
   UserEntity getUserEntityFromCache(String userId);
}
